package org.blim.blackdawn;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.os.Bundle;
import android.os.Debug;
import android.os.Environment;

public class ProfilingActivity extends Activity {
	
	//private static final String TAG = ProfilingActivity.class.getSimpleName();
	private static final boolean METHOD_TRACE = false;
	private static final String METHOD_TRACE_FILENAME = "blackdawn";
	
	public static long mStartTime;
	
	private GameGLSurfaceView mGLView;

	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (METHOD_TRACE) {
        	Debug.startMethodTracing(Environment.getExternalStorageDirectory() + "/" + METHOD_TRACE_FILENAME);
        }
        
        mStartTime = System.currentTimeMillis();
        
        mGLView = new GameGLSurfaceView(this);
     
        // Check if the system supports OpenGL ES 2.0.
        final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
        final boolean supportsEs2 = configurationInfo.reqGlEsVersion >= 0x20000;
     
        if (supportsEs2)
        {
            // Request an OpenGL ES 2.0 compatible context.
            mGLView.setEGLContextClientVersion(2);
     
            // Set the renderer to our demo renderer, defined below.
            mGLView.setRenderer(new GameRenderer(this));
        }
        else
        {
            // This is where you could create an OpenGL ES 1.x compatible
            // renderer if you wanted to support both ES 1 and ES 2.
            return;
        }
     
        setContentView(mGLView);
    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLView.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLView.onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        
        if (METHOD_TRACE) {
        	Debug.stopMethodTracing();
        }
    }
}
